﻿using MediatR;
using S.Produce.Domains;
using S.Produce.Infrastructure;
using S.Produce.Read.Api.Application.Commands.PregnantCommands;

namespace S.Produce.Read.Api.Application.CommandHandlers.PregnantCommandHandlers
{
    public class HintPregnantConnandHandler:IRequestHandler<HintPregnantConnand,List<Pregnant>>
    {
        private readonly IRepository<Pregnant> _repository;

        /// <summary>
        /// 构造方式注入
        /// </summary>
        /// <param name="repository"></param>
        public HintPregnantConnandHandler(IRepository<Pregnant> repository)
        {
            _repository = repository;
        }

        public async Task<List<Pregnant>> Handle(HintPregnantConnand request, CancellationToken cancellationToken)
        {
            return await _repository.GetAllAsync();
        }
    }
}
